var tempfile = null;

function deleteLunboImage(ids) {
	$.ajax({
		url:'https://control.maksdu.com/lunbo/delete',
		data: {
			id:ids
		},
		method:'post',
		success:function(data) {
			if(data) {
				$("#mytable").bootstrapTable('refresh');
			}
		}
	});
}

function deleteLunbo(ids) {
	if(confirm('确定要删除轮播吗？')) {
		$.ajax({
			url:'https://control.maksdu.com/carouse/delete',
			data: {
				id:ids
			},
			method:'post',
			success:function(data) {
				if(data) {
					$("#mytable").bootstrapTable('refresh');
				}
			}
		});
	}
}

$(function(){
	$.ajax({
		url:'https://control.maksdu.com/image/lunbos',
		type:'get',
		success:function(data) {
			$('#imageSelect').empty();
			for(var i=0;i<data.length;i++) {
				$('#imageSelect').append("<option value='"+data[i].id+"'>"+data[i].name+"</option>")
			}
		}
	});
});

function addNewCarouse() {
	$.ajax({
		url:'https://control.maksdu.com/carouse/newadd',
		method: 'post',
		data : {
			fileName:tempfile,
			context: $("input[name='context']").val(),
			title: $("input[name='title']").val(),
			link: $("input[name='targetlink']").val()
		},
		success:function(data) {
			if(data) 
				 $("#mytable").bootstrapTable('refresh');

			reset();
		}
	});
}

function reset() {
	tempfile = null;
	$("#lunbobtn").attr("disabled","disabled");
}

function setTempValue(value) {
	tempfile = value;
}
